package com.konne.nightmare.FastPublicOpinion.ui.information.fragment;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.konne.nightmare.FastPublicOpinion.R;
import com.konne.nightmare.FastPublicOpinion.base.BaseMvpFragment;
import com.konne.nightmare.FastPublicOpinion.mvp.presenter.CGAppointPresenter;
import com.konne.nightmare.FastPublicOpinion.mvp.view.ICGAppointView;
import com.konne.nightmare.FastPublicOpinion.ui.information.activity.CreateGroupActivity;
import com.konne.nightmare.FastPublicOpinion.utils.LoadProgressDialog;

import butterknife.BindView;

/**
 * Create by ws.
 * on Data:2022/1/25  Time:下午 1:21.
 * description: 创建系统分组 .
 */
public class CGAppointFargment extends BaseMvpFragment<ICGAppointView, CGAppointPresenter> implements  ICGAppointView, View.OnClickListener {
    @BindView(R.id.tv_g_num)
    TextView tv_g_num;
    private int num;
    public static CGAppointFargment getInstance(){
        return new CGAppointFargment();
    }
    @Override
    protected CGAppointPresenter createPresenter() {
        return new CGAppointPresenter();
    }

    @Override
    public LoadProgressDialog getLoadDialog() {
        return dialog;
    }

    @Override
    public void cancelLoadDialog() {

    }

    @Override
    public int getLayout() {
        return R.layout.frag_cg_appoint;
    }

    @Override
    public void initView() {
        findViewById(R.id.iv_g_sum).setOnClickListener(this::onClick);
        findViewById(R.id.iv_g_add).setOnClickListener(this::onClick);
        findViewById(R.id.stv_submit).setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.iv_g_sum:
                if(num==0){
                    return;
                }
                num-=1;
                tv_g_num.setText(String.valueOf(num));
                break;
            case R.id.iv_g_add:
                num+=1;
                tv_g_num.setText(String.valueOf(num));
                break;
            case R.id.stv_submit:
                mPresenter.submit();
                break;
        }
    }

    @Override
    public void loadEnd() {
        CreateGroupActivity.start(3);
        getActivity().finish();
    }

    @Override
    public void initData(Bundle savedInstanceState) {

    }
}
